package com.zhuss.controller.core;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.zhuss.bean.bo.core.role.CreateRoleBo;
import com.zhuss.bean.bo.core.role.DeleteRoleBo;
import com.zhuss.bean.bo.core.role.RolePermissionBindBo;
import com.zhuss.bean.bo.core.role.RoleUserBindBo;
import com.zhuss.bean.bo.core.role.StartRoleBo;
import com.zhuss.bean.bo.core.role.StopRoleBo;
import com.zhuss.bean.bo.core.role.UpdateRoleBo;
import com.zhuss.common.BaseController;
import com.zhuss.common.OperateService;
import com.zhuss.core.role.RoleOperateServiceExt;
import com.zhuss.exception.AabException;


/**
 * 角色操作 controller
 * @Author zhushanshuo
   @Date 2019-11-27 19:58
 *
 */
  
 
@RestController
@RequestMapping("/role")
public class RoleOperateController extends BaseController {
	
	@Autowired
	@Qualifier("roleOperateService")
	private OperateService<Void, Object> roleOperateService;
	
	@Autowired
	@Qualifier("roleOperateServiceExt")
	private RoleOperateServiceExt roleOperateServiceExt;
	
	/**
	 * 创建
	 * @param bo
	 * @throws AabException
	 */
	@ResponseBody
    @PostMapping("/create")
    public void create(@RequestBody CreateRoleBo bo) throws AabException {
		
		roleOperateService.create(bo);
    }
	
	
	/**
	 * 修改
	 * @param bo
	 * @throws AabException
	 */
	@ResponseBody
    @PostMapping("/update")
    public void update(@RequestBody UpdateRoleBo bo) throws AabException {
		
		roleOperateService.update(bo);
    }
	
	/**
	 * 删除
	 * @param bo
	 * @throws AabException
	 */
	@ResponseBody
    @PostMapping("/delete")
    public void delete(@RequestBody DeleteRoleBo bo) throws AabException {
		
		roleOperateService.delete(bo);
    }
	
	
	/**
	 * 启用
	 * @param bo
	 * @throws AabException
	 */
	@ResponseBody
    @PostMapping("/start")
    public void start(@RequestBody StartRoleBo bo) throws AabException {
		
		roleOperateServiceExt.start(bo);
    }
	
	
	/**
	 * 停用
	 * @param bo
	 * @throws AabException
	 */
	@ResponseBody
    @PostMapping("/stop")
    public void stop(@RequestBody StopRoleBo bo) throws AabException {
		
		roleOperateServiceExt.stop(bo);
    }
	
	
	/**
	 * 给角色绑定权限
	 * @param bo
	 * @throws AabException
	 */
	@ResponseBody
    @PostMapping("/rolePermissionBind")
    public void rolePermissionBind(@RequestBody RolePermissionBindBo bo) throws AabException {
		
		roleOperateServiceExt.rolePermissionBind(bo);
    }
	
	/**
	 * 给角色绑定用户
	 * @param bo
	 * @throws AabException
	 */
	@ResponseBody
    @PostMapping("/roleUserBind")
    public void roleUserBind(@RequestBody RoleUserBindBo bo) throws AabException {
		
		roleOperateServiceExt.roleUserBind(bo);
    }


	
}
